package com.example.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        Button button1 = findViewById(R.id.button_1);
        button1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 发送数据给下一个活动
                Log.d("MainActivity", "按钮点击事件触发");
                Intent intent = new Intent(MainActivity.this, FirstActivity.class);
                try {
                    startActivity(intent);
                } catch (Exception e) {
                    Log.e("MainActivity", "跳转失败: " + e.getMessage());
                }

            }
        });
    }
}
